package com.oauth.twitter.server.beans;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.oauth.service.generic.beans.OAuthServiceBean;
import com.oauth.service.generic.constants.OAuthTokenState;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TwitterServiceBean implements OAuthServiceBean {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long key;

	@Persistent
	private Long memberId;

	@Persistent
	private String twitterId;

	@Persistent
	private String accessToken;

	@Persistent
	private String accessTokenSecret;

	@Persistent
	private int state;

	@Persistent
	private Date creationDate;

	@Persistent
	private Date lastUpdateDate;

	public TwitterServiceBean() {
		super();
	}

	public TwitterServiceBean(Long pMemberId, String pToken, String pTokenSecret, String pTwitterId) {
		super();
		memberId = pMemberId;
		accessToken = pToken;
		accessTokenSecret = pTokenSecret;
		twitterId = pTwitterId;
	}

	/**
	 * @return the key
	 */
	public Long getKey() {
		return key;
	}

	/**
	 * @param pKey
	 *            the key to set
	 */
	public void setKey(Long pKey) {
		key = pKey;
	}

	/**
	 * @return the twitterId
	 */
	public String getTwitterId() {
		return twitterId;
	}

	/**
	 * @param pTwitterId
	 *            the twitterId to set
	 */
	public void setTwitterId(String pTwitterId) {
		twitterId = pTwitterId;
	}

	/**
	 * @return the state
	 */
	public OAuthTokenState getState() {
		return OAuthTokenState.getState(state);
	}

	/**
	 * @param pState
	 *            the state to set
	 */
	public void setState(OAuthTokenState pState) {
		state = pState.getState();
	}

	/**
	 * @return the memberId
	 */
	public Long getMemberId() {
		return memberId;
	}

	/**
	 * @param pMemberId
	 *            the memberId to set
	 */
	public void setMemberId(Long pMemberId) {
		memberId = pMemberId;
	}

	/**
	 * @return the accessToken
	 */
	public String getAccessToken() {
		return accessToken;
	}

	/**
	 * @param pAccessToken
	 *            the accessToken to set
	 */
	public void setAccessToken(String pAccessToken) {
		accessToken = pAccessToken;
	}

	/**
	 * @return the accessTokenSecret
	 */
	public String getAccessTokenSecret() {
		return accessTokenSecret;
	}

	/**
	 * @param pAccessTokenSecret
	 *            the accessTokenSecret to set
	 */
	public void setAccessTokenSecret(String pAccessTokenSecret) {
		accessTokenSecret = pAccessTokenSecret;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param pCreationDate
	 *            the creationDate to set
	 */
	public void setCreationDate(Date pCreationDate) {
		creationDate = pCreationDate;
	}

	/**
	 * @return the lastUpdateDate
	 */
	public Date getLastUpdateDate() {
		return lastUpdateDate;
	}

	/**
	 * @param pLastUpdateDate
	 *            the lastUpdateDate to set
	 */
	public void setLastUpdateDate(Date pLastUpdateDate) {
		lastUpdateDate = pLastUpdateDate;
	}

}
